{% extends "base.htm" %}

{% block header_title %}文章列表{% end %}
{% block body %}
{% include "header.htm" %}
<div class="am-container">
    <div class="am-g">
        <div class="am-u-lg-9 am-u-sm-12">
            <div class="am-panel am-panel-default">
              <div class="am-panel-hd">
                <ol class="minos-breadcrumb am-breadcrumb am-breadcrumb-slash">
                    <li><a href="/">首页</a></li>
                    <li class="am-active">{{ sort["name"] }}</li>
                </ol>
              </div>
              <div class="am-panel-bd minos-sorts am-text-sm">
                  {{ sort.get('intro') }}
              </div>
              <table class="am-table minos-list am-text-sm am-table-bordered am-table-hover am-scrollable-horizontal">
                  <tr class="null am-primary">
                    <td width="15%" class="am-hide-sm-down">时间</td>
                    <td>标题</td>
                    <td class="am-text-center am-hide-sm-down" width="10%">状态</td>
                    <td class="am-text-right" width="10%">作者</td>
                  </tr>
                  {% for post in posts %}
                  <tr class="row">
                    <td class="am-link-muted am-hide-sm-down">{{ time_span(post['time']) }}</td>
                    <td><a href="/post/{{ post['_id'] }}">{{ post['title'] }}</a></td>
                    <td class="am-text-center am-hide-sm-down">
                        {% if post['charge'] and current_user["username"] not in post["buyer"] %}
                        <span class="am-badge am-badge-warning">{{ post['charge'] }}金币</span>
                        {% elif current_user["username"] in post["buyer"] %}
                        <span class="am-badge am-badge-secondary">已购买</span>
                        {% else %}
                        <span class="am-badge am-badge-success">免费</span>
                        {% end %}
                    </td>
                    <td class="am-text-right"><a href="/user/detail/{{ post['user'] }}">{{ post['user'] }}</a></td>
                  </tr>
                  {% end %}
              </table>
              <div class="am-panel-footer">
                  {% raw pagenav(now = page, count = count, each = each, url = '/sort/'+str(sort['_id'])+'/%d') %}
                  <div class="am-cf"></div>
              </div>
            </div>
        </div>
        <div class="am-u-lg-3">
            {% include "self.htm" %}
        </div>
    </div>
</div>

{% end %}
{% block footer_static %}
    <script src="{{ static_url('assets/js/app.js') }}"></script>
{% end %}